﻿using Xtensive.Orm;

namespace UniqueIndex.Model
{
    /*
     * To declare unique index, use [Index] attribute, pass there at least one field name and set Unique property to true
     * Also you can set the desired index name, this is optional
     */
    [HierarchyRoot]
    [Index("Isbn", Unique = true, Name = "IX_ISBN")]
    public class Book : Entity
    {
        [Field, Key]
        public int Id { get; set; }

        [Field]
        public string Title { get; set; }

        [Field]
        public string Isbn { get; set; }

        public Book(Session session) :
            base(session) {}
    }
}